//
//  FProgressIndicatorCell.m
//  SolarSeek
//
//  Created by Erick Fejta on 04/10/12.
//  Copyright 2004 Erick Fejta. All rights reserved.
//

#import "FProgressIndicatorCell.h"


@implementation FProgressIndicatorCell
- (id)init {
	if(self = [super initImageCell:nil]) {
		_progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0,0,50,20)];
		[_progressIndicator setMaxValue:1.0];
	}
	return self;
}


- (id)copyWithZone:(NSZone *)zone {
	id o;
	if(o = [super copyWithZone:zone]) {
		[_progressIndicator retain];
	}
	return o;
}

- (void)dealloc {
	[_progressIndicator release];
	[super dealloc];
}


#pragma mark -

- (void)setObjectValue:(id)obj {
	[_progressIndicator setMaxValue:1.0];
	[_progressIndicator setDoubleValue:[obj doubleValue]];
}

#pragma mark -

- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)view {
	[view addSubview:_progressIndicator];
	float extra = (frame.size.height - 20);
	if(extra > 0) {
		frame.origin.y+=(extra/2);
		frame.size.height = 20;
	}
	[_progressIndicator setFrame:frame];	
	[_progressIndicator setNeedsDisplay:YES];
	[_progressIndicator displayIfNeededIgnoringOpacity];
	[_progressIndicator removeFromSuperview];
}

@end
